"use client";

import React from "react";
import { ConfigProvider, App } from "antd";
import { ProConfigProvider } from "@ant-design/pro-components";
import zhCN from "antd/locale/zh_CN";
import { AuthProvider } from "./components/AuthProvider";
import LayoutWrapper from "./components/LayoutWrapper";
import theme from "./theme/antd-theme";
import "@ant-design/v5-patch-for-react-19";
import "dayjs/locale/zh-cn";
import dayjs from "dayjs";
import { PortalProvider } from "@/components/PortalProvider";

dayjs.locale("zh-cn");

interface ProvidersProps {
  children: React.ReactNode;
}

const Providers: React.FC<ProvidersProps> = ({ children }) => {
  return (
    <ConfigProvider locale={zhCN} theme={theme}>
      <ProConfigProvider
        hashed={false}
        token={{
          colorPrimary: "#69cac3",
        }}
      >
        <App>
          <AuthProvider>
            <PortalProvider>
              <LayoutWrapper>{children}</LayoutWrapper>
            </PortalProvider>
          </AuthProvider>
        </App>
      </ProConfigProvider>
    </ConfigProvider>
  );
};

export default Providers;
